package com.xjl.controller;

import com.xjl.domain.User;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
public class UserController {


    @PostMapping(value = "/user")
    public String insertUser(@RequestBody User user){
        System.out.println("insertUser");
        System.out.println(user);
        return "insertUser";
    }

    @PostMapping(value = "/users")
    public String insertUsers(@RequestBody List<User> user){
        System.out.println("insertUsers");
        System.out.println(user);
        return "insertUsers";
    }


    @RequestMapping("/testRquestParam")
    public String testRquestParam(@RequestParam(value = "id",required = false) Integer uid,@RequestParam("name") String name, @RequestParam("likes")String[] likes){
        System.out.println("testRquestParam");
        System.out.println(uid);
        System.out.println(name);
        System.out.println(Arrays.toString(likes));
        return "testRquestParam";
    }

    @RequestMapping("/testRquestParam1")
    public String testRquestParam(User user){
        System.out.println("testRquestParam1");
        System.out.println(user);
        return "testRquestParam1";
    }
}
